<!doctype html>
<html lang="zh-CN" th:replace="admin-layout :: layout(~{::title}, ~{}, ~{::script}, ~{::body}, 'exam-list')"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <title>考试管理</title>
    <script th:src="@{/custom/js/admin-exam-paper.js}"></script>
    <script th:src="@{/custom/js/admin-exam-user.js}"></script>
    <script>
        $("#selectPaperBtn").click(function () {
            openWindowBtn("选择试卷", "/admin/select/paper", $("#paperForm").serialize(), function () {
                if (childSelections.length > 0) {
                    $("#paperIds").val(childSelections.toString());
                    ajaxJson("/admin/exam/ajax/save/paper", $("#paperForm").serialize(), function (res) {
                        if (res.status) {
                            $("#paperForm>[name='noDataIds']").val(res.data);
                            refreshTablePaper();
                        } else {
                            noMsg("保存失败");
                        }
                    })
                }
            })
        })
        $("#selectUserBtn").click(function () {
            openWindowBtn("选择用户", "/admin/select/user", $("#userForm").serialize(), function () {
                if (childSelections.length > 0) {
                    $("#userIds").val(childSelections.toString());
                    ajaxJson("/admin/exam/ajax/save/user", $("#userForm").serialize(), function (res) {
                        if (res.status) {
                            $("#userForm>[name='noDataIds']").val(res.data);
                            refreshTableUser();
                        } else {
                            noMsg("保存失败");
                        }
                    })
                }
            })
        })
    </script>
</head>
<body>
<!--<ol class="breadcrumb">
    <li><a th:href="@{/admin/exam/list}">考试列表</a></li>
    <li class="active">考试管理</li>
</ol>-->
<div>
    <form id="paperForm">
        <input type="hidden" name="id" th:value="${exam.id}">
        <input type="hidden" name="paperIds" id="paperIds">
        <input type="hidden" name="noDataIds" th:value="${paperIds}">
    </form>
    <form id="userForm">
        <input type="hidden" name="id" th:value="${exam.id}">
        <input type="hidden" name="userIds" id="userIds">
        <input type="hidden" name="noDataIds" th:value="${userIds}">
    </form>
    <form id="toolbar">
        <input type="hidden" name="examId" th:value="${exam.id}">
    </form>
    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#paper" aria-controls="paper" role="tab"
                                                  data-toggle="tab">试卷</a></li>
        <li role="presentation"><a href="#user" aria-controls="user" role="tab" data-toggle="tab">用户</a></li>
    </ul>

    <!-- Tab panes -->
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="paper">
            <div class="fyl-mb20">
                <button type="button" class="btn btn-primary" id="selectPaperBtn">选择试卷</button>
                <button type="button" class="btn btn-danger" id="removePaper" disabled>移除试卷</button>
            </div>
            <table id="tablePaper" data-url="/admin/exam/ajax/paper/list"></table>
        </div>
        <div role="tabpanel" class="tab-pane" id="user">
            <div class="fyl-mb20">
                <button type="button" class="btn btn-primary" id="selectUserBtn">选择用户</button>
                <button type="button" class="btn btn-danger" id="removeUser" disabled>移除用户</button>
            </div>
            <table id="tableUser" data-url="/admin/exam/ajax/user/list"></table>
        </div>
    </div>

</div>
</body>
</html>